package com.example.strategy.pay;

import java.util.HashMap;
import java.util.Map;

/**
 * 支付场景
 */
public class PaymentContext {

    private static Map<PayWay, IPaymentStrategy> payStrategys = new HashMap<>();
    private IPaymentStrategy defaultPayStrategy = new DefaultPayStrategy();

    static {
        payStrategys.put(PayWay.Ali_Pay, new AliPayStrategy());
        payStrategys.put(PayWay.Wechat_Pay, new WechatPayStrategy());
        payStrategys.put(PayWay.Union_Pay, new UnionPayStrategy());
    }


    public IPaymentStrategy getPayStrategy(PayWay payWay) {
        if (payStrategys.containsKey(payWay)) {
            return payStrategys.get(payWay);
        }
        return defaultPayStrategy;
    }


}
